package com.clw.service.impl;


import com.clw.dataobject.Feature;
import com.clw.repository.FeatureRepository;
import com.clw.service.FeatureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2017-12-15.
 */
@Service
public class FeatureServiceImpl implements FeatureService {

    @Autowired
    private FeatureRepository repository;

    @Override
    public List<Feature> findAll() {
        return repository.findByStatus(1);
    }

    @Override
    public Feature findOne(Integer id) {
        return repository.findOne(id);
    }

    @Override
    public Feature save(Feature features) {
        return repository.save(features);
    }

    @Override
    public Long getChildrenCount(Integer id) {
        return repository.countByPidAndStatus(id,1);
    }

    @Override
    public void del(Feature features) {
        repository.delete(features);
    }

    @Override
    public Feature add(Feature feature) {
        feature.setCreateTime(new Date());
        feature.setStatus(1);
        return repository.save(feature);
    }

    @Override
    public List<Feature> getSimpleList() {
        return repository.getSimpleList();
    }
}
